package com.alliance.shuwei.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alliance.shuwei.entity.ResourceProvider;
import com.alliance.shuwei.service.ProviderService;

@RestController
@RequestMapping(value = "/api/v1/providers", produces = { "application/json" })
public class ProviderResource {
	@Autowired
	private ProviderService providerService;

	@RequestMapping(method = RequestMethod.GET)
	@ResponseBody
	public List<ResourceProvider> getAllProviders() {
		return providerService.getAllProvider();
	}

	@RequestMapping(method = RequestMethod.POST)
	@ResponseBody
	public ResourceProvider createProvider(ResourceProvider provider) {
		return providerService.createProvider(provider);
	}

	@RequestMapping(value = "/{id}", method = RequestMethod.GET)
	@ResponseBody
	public ResourceProvider getProviderById(@PathVariable("id") int id) {
		return providerService.getProviderById(id);
	}
}
